package com.huangpuweb.task.service.imp;

import com.huangpuweb.task.model.*;
import com.huangpuweb.task.service.SyncZYJJZDataService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SyncZYJJZDataServiceImp extends BaseZYJJZdataServiceImp implements SyncZYJJZDataService {


    @Override
    public List<ZyDwdTfcOptSpeedRidAmapRt> getZyDwdTfcOptSpeedRidAmapRtByRid(String roadId) {
        String sql="select * from dwd_tfc_opt_speed_rid_amap_rt where rid =? ORDER BY jhpt_update_time desc limit 0,1";
        return  getEntryList(sql,new ZyDwdTfcOptSpeedRidAmapRtRowMapper(),new Object[]{roadId});

    }

    @Override
    public QZDwdDzGjDitieJczrsDi getListQZDwdDzGjDitieJczrsDi(String code,String lastday) {
        //String sql="select DISTINCT id,zdid,zdmc,gd_jd,gd_wd,dwd_zjid,jzrs,czrs,kssj,jssj,jhpt_update_time from dwd_dz_gj_ditie_jczrs_di where zdmc=? and kssj >=? ORDER BY zdid asc";
        String sql="select zdid,zdmc,sum(jzrs) as jzrs,sum(czrs) as czrs from dwd_dz_gj_ditie_jczrs_di where zdmc=? and kssj >=?  group by zdid ;";
        return getEntry(sql,new QZDwdDzGjDitieJczrsDiDataRowMapper(),new Object[]{code,lastday});
    }

    @Override
    public List<QZDwdDzGjDitieJczrsDi> getListHpSubwayExitInfo(String zdid,String lastday) {
        String sql="select * from dwd_dz_gj_ditie_jczrs_di where zdid =? and kssj >=? order by kssj asc";
        return getEntryList(sql,new QZDwdDzGjDitieJczrsDiDataRowMapper(),new Object[]{zdid,lastday});
    }

    @Override
    public List<ZyRidPredShort> getListZyRidPredShort(List<String> roadIds, int size) {
        String str = "";
        if (roadIds != null) {
            for (String roadname : roadIds) {
                // 根据
                str = str + "'" + roadname + "'" + ",";
            }

            str = str.substring(0, str.length() - 1);
        }
        String sql="select pred_time,rid,congestion_index,speed,vol_in,step_index from rid_pred_short where rid in (" + str + ")order by pred_time desc limit 0,?";
        return getEntryList(sql,new ZyRidPredShortRowMapper(),new Object[]{size});
    }
}
